<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * Creates the opening form tag
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <sean@picnicphp.com>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */

/**
 *
 * @param array $params
 * @param Pfw_Smarty_Standard $smarty
 */
function smarty_block_form($params, $content, &$smarty, &$repeat) {
    if (!$repeat) {
        list($args, $attrs) = $smarty->_filterAttrs($params);

        if (!empty($params['controller']) and !empty($params['action'])) {
            $attrs['action'] = $smarty->_generateUrlFor($args);
        }
        if (empty($attrs['method'])) {
            $attrs['method'] = !empty($args['method']) ? $args['method'] : "post";
        }
        if (empty($attrs['name']) and !empty($args['name'])) {
            $attrs['name'] = $args['name'];
        }

        return $smarty->_generateElement("form", $attrs, $content);
    }
}
?>